﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

using Autofac;
using Autofac.Builder;

using Owlpal.Core.Mvc;
using Owlpal.Core.Plugins;

namespace Owlpal.Core
{
    /// <summary>
    /// Represents the Class that initializes the Owlpal Application.
    /// </summary>
    public class OwlpalSystem : HttpApplication
    {
        private const string APPLICATION_CONTAINER_KEY = "owlpal_application_container";
        
        protected void Application_Start()
        {
            // 1. Initialize hosting environment
            // 2. Initialize all Plugins
            // 3. 
            Application[APPLICATION_CONTAINER_KEY] = new OwlpalContainer();
            OwlpalControllerFactory factory = new OwlpalControllerFactory((Container)Application[APPLICATION_CONTAINER_KEY]);
            ControllerBuilder.Current.SetControllerFactory(factory);
           
        }

        protected void Application_End()
        { 
        
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        { 
        
        }

        protected void InitializeHostingEnvironment()
        { 
        
        }

        private void InitializePlugins(IEnumerable<IPluginInstaller> installers)
        { 
        
        }
    }
}
